package com.example.demo.SpringIoC.model;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan({"com.example.demo.SpringIoC"})
@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
		//获取Spring上下文对象
		ApplicationContext context=SpringApplication.run(DemoApplication.class, args);
		//从Spring上下文中获取对象
		User user1= (User) context.getBean("u1");
		User user2= (User) context.getBean("u2");
//		User user1= (User) context.getBean("user1");
//		User user2= (User) context.getBean("user2");
		System.out.println(user1);
		System.out.println(user2);
//		System.out.println(user2);

	}

}
